%% NOTE: Order of the deps matters!
{elixir_deps, []}.

{deps,
    [ emqx
    , emqx_retainer
    , emqx_management
    , emqx_reloader
    , emqx_bridge_mqtt
    , emqx_sn
    , emqx_coap
    , emqx_stomp
    , emqx_auth_clientid
    , emqx_auth_username
    , emqx_auth_http
    , emqx_auth_jwt
    , emqx_auth_mysql
    , emqx_web_hook
    , emqx_delayed_publish
    , emqx_recon
    , emqx_psk_file
    , emqx_rule_engine
    , emqx_plugin_template
    ]}.

%% Added to deps list for 'cloud' profile
{cloud_deps,
    [ emqx_lwm2m
    , emqx_auth_ldap
    , emqx_auth_pgsql
    , emqx_auth_redis
    , emqx_auth_mongo
    , emqx_lua_hook
    , emqx_dashboard
    , emqx_statsd
    ]}.

{edge_deps,
    [emqx_cube]}.

{relx,
    [ {include_src,false}
    , {extended_start_script,false}
    , {generate_start_script,false}
    , {sys_config,false}
    , {vm_args,false}
    , {release, {emqx, git_describe},
        [ kernel
        , sasl
        , crypto
        , public_key
        , asn1
        , syntax_tools
        , ssl
        , os_mon
        , inets
        , compiler
        , runtime_tools
        , gproc
        , esockd
        , clique
        , getopt
        , cuttlefish
        , jsx
        , cowboy
        , pbkdf2
        , bcrypt
        , mysql
        , emqx
        , {mnesia, load}
        , {ekka, load}
        , {emqx_sn, load}
        , {emqx_coap, load}
        , {emqx_recon, load}
        , {emqx_stomp, load}
        , {emqx_management, load}
        , {emqx_rule_engine, load}
        , {emqx_retainer, load}
        , {emqx_reloader, load}
        , {emqx_bridge_mqtt, load}
        , {emqx_delayed_publish, load}
        , {emqx_web_hook, load}
        , {emqx_auth_clientid, load}
        , {emqx_auth_username, load}
        , {emqx_auth_http, load}
        , {emqx_auth_mysql, load}
        , {emqx_auth_jwt, load}
        , {emqx_psk_file, load}
        ]}
    , {overlay,
        [ {mkdir,"etc/"}
        , {mkdir,"log/"}
        , {mkdir,"data/"}
        , {mkdir,"data/mnesia"}
        , {mkdir,"data/configs"}
        , {mkdir,"data/scripts"}
        , {template,"bin/emqx_env","bin/emqx_env"}
        , {template,"bin/emqx","bin/emqx"}
        , {template,"bin/emqx_ctl","bin/emqx_ctl"}
        , {template,"bin/emqx.cmd","bin/emqx.cmd"}
        , {template,"bin/emqx_ctl.cmd","bin/emqx_ctl.cmd"}
        , {copy,"{{output_dir}}/../../conf/plugins","etc/"}
        , {template,"{{output_dir}}/../../conf/emqx.conf","etc/emqx.conf"}
        , {template,"{{output_dir}}/../../conf/ssl_dist.conf","etc/ssl_dist.conf"}
        , {template,"{{output_dir}}/../../conf/plugins/emqx_bridge_mqtt.conf", "etc/plugins/emqx_bridge_mqtt.conf"}
        , {template,"{{output_dir}}/../../conf/plugins/emqx_coap.conf", "etc/plugins/emqx_coap.conf"}
        , {template,"{{output_dir}}/../../conf/plugins/emqx_psk_file.conf", "etc/plugins/emqx_psk_file.conf"}
        , {template,"{{output_dir}}/../../conf/plugins/emqx_auth_http.conf", "etc/plugins/emqx_auth_http.conf"}
        , {template, "data/loaded_plugins.tmpl", "data/loaded_plugins"}
        , {copy,"{{output_dir}}/../../conf/acl.conf","etc/acl.conf"}
        , {copy,"bin/nodetool","bin/nodetool"}
        , {copy,"{{output_dir}}/../../conf/schema","releases/{{rel_vsn}}/"}
        , {copy,"bin/install_upgrade_escript", "bin/install_upgrade_escript"}
        , {template,"{{output_dir}}/../../lib/emqx/etc/{{vm_args_file}}","etc/vm.args"}
        , {copy, "{{output_dir}}/../../lib/emqx/etc/certs","etc/"}
        , {copy, "{{output_dir}}/../../lib/cuttlefish/cuttlefish","bin/"}
        , {copy, "{{output_dir}}/../../lib/emqx_psk_file/etc/psk.txt", "etc/psk.txt"}
        ]}
    ]}.

{elixir_relx_apps,
    []}.

{edge_relx_apps,
    [{emqx_cube, load}]}.

{cloud_relx_apps,
    [ {emqx_auth_ldap, load}
    , {emqx_auth_mongo, load}
    , {emqx_auth_pgsql, load}
    , {emqx_auth_redis, load}
    , {emqx_dashboard, load}
    , {emqx_lua_hook, load}
    , {emqx_lwm2m, load}
    , {emqx_statsd, load}
    , {observer, load}
    , luerl
    , xmerl
    ]}.

{cloud_relx_overlay,
    [ {template,"{{output_dir}}/../../conf/plugins/emqx_lwm2m.conf", "etc/plugins/emqx_lwm2m.conf"}
    , {copy,"{{output_dir}}/../../lib/emqx_lwm2m/lwm2m_xml","etc/"}
    ]}.

{edge_relx_overlay,
    []}.

{edoc_opts, [{preprocess,true}]}.
{erl_opts, [warn_unused_vars,warn_shadow_vars,warn_unused_import,
            warn_obsolete_guard,debug_info]}.

{xref_checks, [undefined_function_calls,undefined_functions,locals_not_used,
               deprecated_function_calls,warnings_as_errors,
               deprecated_functions]}.
{cover_enabled, true}.
{cover_opts, [verbose]}.
{cover_export_enabled, true}.

{plugins, [rebar3_run]}.

{post_hooks, [ {"(linux|darwin|solaris|freebsd|netbsd|openbsd)", compile, "./post-compile.sh"}
             , {"win32", compile, "post-compile.cmd"}]}.
